﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.DAO;

public partial class UserControl_ucFindJob : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadJob();
        }
    }

    private void loadJob()
    {
        TblJobsDAO jobDAO = new TblJobsDAO(Global.CONNECTION_STRING);
        grdJobList.DataSource = jobDAO.GetJob(Global.ConvertToInt(txtJobID.Text));
        grdJobList.DataBind();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        loadJob();
    }
    protected void btnExt_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
    protected void grdJobList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lb_ApprovalStatus = (Label)e.Row.Cells[7].FindControl("lbApprovalStatus");
            int AppStatus = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "ApprovalStatus"));
            if (AppStatus == 1)
                lb_ApprovalStatus.Text = " Approved ";
            else
                lb_ApprovalStatus.Text = " Pending Approval";

            Label lb_QuotationStatus = (Label)e.Row.Cells[8].FindControl("lbQuotationStatus");
            int QuotaStatus = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "QuotationStatus"));

            if (QuotaStatus == 1)
                lb_QuotationStatus.Text = "Quoted";
            else
                lb_QuotationStatus.Text = "Waiting for quote";
        }
    }

    protected void grdJobList_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        
        grdJobList.PageIndex = e.NewPageIndex;
        loadJob();
    }
}
